package com.k2091.washcar.service.impl;

import com.k2091.washcar.entity.FormInline;
import com.k2091.washcar.entity.Users;
import com.k2091.washcar.entity.UsersCar;
import com.k2091.washcar.mapper.UsersCarMapper;
import com.k2091.washcar.mapper.UsersMapper;
import com.k2091.washcar.service.IUsersService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author author
 * @since 2021-06-01
 */
@Service
public class UsersServiceImpl extends ServiceImpl<UsersMapper, Users> implements IUsersService {

    @Autowired
    private UsersMapper usersMapper;
    @Autowired
    private UsersCarMapper usersCarMapper;

    //用户添加车辆
    @Override
    public int addCar(UsersCar usersCar) {
        return usersCarMapper.insert(usersCar);
    }

    //用户查询自己的车辆
    @Override
    public List<UsersCar> selectByUserId(Long id) {
        return usersMapper.selectByUserId(id);
    }

    //用户完善个人信息
    @Override
    public int insertMessage(Users users) {
        return usersMapper.insert(users);
    }

    @Override
    public List<Users> selectUser(FormInline formInline) {
        return usersMapper.selectUser(formInline);
    }

    @Override
    public int addUser(Users users) {
        return usersMapper.insert(users);
    }

    @Override
    public int upUser(Users users){return usersMapper.updateById(users);}

    @Override
    public int upStatus(Long id,@Param("status") int status) {
        return  usersMapper.upStatus(id,status);
    }

    @Override
    public int userDelete(Long id) {
        return usersMapper.deleteById(id);
    }

    public Users selectUsersById(Long id){
        return usersMapper.selectById(id);
    }
}
